﻿
#pragma once

#include <QtCore>

#ifdef Q_OS_WIN

#include "DirMonitor.h"

#include <QObject>
#include <QDebug>
#include <QString>
#include <QTimer>
#include <QDir>
#include <QThread>
#include <QtConcurrent>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>

#include <windows.h>
#include <iostream>

class DirMonitorForWin : public DirMonitor
{
    Q_OBJECT
public:
    explicit DirMonitorForWin(QObject *parent = nullptr);
    virtual ~DirMonitorForWin() override;

    virtual void SetRootDirPath(const QString &path) override;

Q_SIGNALS:
    void fileModified(const QString &path);

private:
    void watchDirInThread(const QString &dirPath);
    void detectFileClosed();

private:
    QString m_dirPath;
    bool m_isInWatching;
    QFuture<void> m_fut;
    QList<QString> m_fileClosedDetectList;
};

#endif
